Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BrowserKit] Rename Client to Browser #30541

Merged
merged 1 commit into from Mar 12, 2019
Merged

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Mar 12, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR n/a

Client is very generic and used in 3 places: BrowserKit, HttpKernel, and FramewrokBundle. Each Client extends another one. So, to make things clearer, I'd like to rename Client to Browser like this:

Symfony\Component\BrowerKit\Client -> AbstractBrowser
Symfony\Component\HttpKernel\Client -> HttpKernelBrowser
Symfony\Bundle\FrameworkBundle\Client -> KernelBrowser

The next PR will introduce an HttpBrowser based on the new HttpClient component :)

@nicolas-grekas nicolas-grekas changed the title Rename Client to Browser [BrowserKit] Rename Client to Browser Mar 12, 2019
@fabpot fabpot force-pushed the client-rename branch 2 times, most recently from b5151a7 to 3a84669 Compare March 12, 2019 20:38
@fabpot fabpot merged commit dbe4f86 into symfony:master Mar 12, 2019
fabpot added a commit that referenced this pull request Mar 12, 2019
This PR was merged into the 4.3-dev branch.

Discussion
----------

[BrowserKit] Rename Client to Browser

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | yes
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

`Client` is very generic and used in 3 places: BrowserKit, HttpKernel, and FramewrokBundle. Each Client extends another one. So, to make things clearer, I'd like to rename Client to Browser like this:

Symfony\Component\BrowerKit\Client -> AbstractBrowser
Symfony\Component\HttpKernel\Client -> HttpKernelBrowser
Symfony\Bundle\FrameworkBundle\Client -> KernelBrowser

The next PR will introduce an `HttpBrowser` based on the new HttpClient component :)

Commits
-------

dbe4f86 renamed Client to Browser
*
* @param array $options An array of options to pass to the createKernel method
* @param array $server An array of server parameters
*
* @return Client A Client instance
* @return KernelBrowser A KernelBrowser instance
*/
protected static function createClient(array $options = [], array $server = [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we rename that method too ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about renaming methods but I think that's too much. What others think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a hard copy pasting you could also add return type hints on methods.

@stof
Copy link
Member

stof commented Mar 13, 2019

This is a BC break, because the BC class Symfony\Bundle\FrameworkBundle\Client does not extend the BC class Symfony\Component\BrowerKit\Client

@stof
Copy link
Member

stof commented Mar 13, 2019

I think you will need to use class aliases here instead., to preserve the class hierarchy.

@fabpot fabpot deleted the client-rename branch March 17, 2019 07:41
@Devristo
Copy link
Contributor

Devristo commented Apr 9, 2019

Yes, it breaks at least https://github.com/FriendsOfBehat/SymfonyExtension and https://github.com/minkphp/MinkBrowserKitDriver.

For now people can workaround it by adding the following to their test bootstrap:

class_alias(\Symfony\Component\BrowserKit\AbstractBrowser::class, 'Symfony\Component\BrowserKit\Client');

This should be near the top, as it will only work when the class has not yet been autoloaded.

@fabpot
Copy link
Member Author

fabpot commented Apr 9, 2019

@Devristo Can you create a new issue... and if you can provide a PR, that would be wonderful :)

fabpot added a commit that referenced this pull request Apr 15, 2019
… to Browser (Devristo)

This PR was squashed before being merged into the 4.3-dev branch (closes #31040).

Discussion
----------

[BrowserKit] Fixed BC-break introduced by rename of Client to Browser

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31039
| License       | MIT
| Doc PR        |

Since #30541 the inheritance hierarchy of `\Symfony\Component\BrowserKit\Client` has changed. Notably the test.client no longer is an instance of `\Symfony\Component\BrowserKit\Client`.

This PR uses `class_alias` to fix the class hierarchy similarly as has been done in Twig. In this case I copied the approach of `Twig_TokenParser_AutoEscape` and `\Twig\TokenParser\AutoEscapeTokenParser`

Commits
-------

6a94dea [BrowserKit] Fixed BC-break introduced by rename of Client to Browser
@fabpot fabpot mentioned this pull request May 9, 2019
fabpot added a commit that referenced this pull request Jun 6, 2019
…icolas-grekas)

This PR was merged into the 4.3 branch.

Discussion
----------

[FramworkBundle][HttpKernel] fix KernelBrowser BC layer

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #31762
| License       | MIT
| Doc PR        | -

Swap the order of inheritance to preserve BC with legacy `Client` type hints.
From #30541

Commits
-------

1a4c254 [FramworkBundle][HttpKernel] fix KernelBrowser BC layer
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Jun 8, 2020
…bstractBrowser since SF 4.3 (Calex92)

This PR was merged into the 4.4 branch.

Discussion
----------

[Browserkit] The Client class has been replaced by the AbstractBrowser since SF 4.3

I noticed that in the BrowserKit documentation, there was multiple references to the old ``Symfony\Component\BrowserKit\Client`` class instead of the ``Symfony\Component\BrowserKit\AbstractBrowser`` one.

See [symfony/symfony#30541

There was a previous merge request for SF5 here (#12717), but I don't know if it was possible for me to use it since I'm quite new with Github best practice about contribution.

Don't hesitate to tell me if I'm wrong!

Commits
-------

a3ff4e0 The Client class has been replaced by the AbstractBrowser since SF 4.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants